package com.example.controller;

import com.example.config.InfoConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 动态变更示例-入口
 *
 * @author sunhui
 */
@RestController
public class ConfigClientController {

    /**
     * 应用名称
     */
    @Value("${spring.application.name}")
    private String applicationName;

    /**
     * eureka地址
     */
    @Value("${eureka.client.serviceUrl.defaultZone}")
    private String eurekaServers;

    /**
     * 获取测试信息
     */
    @Resource
    private InfoConfig infoConfig;

    @RequestMapping("/config")
    public String getConfig() {
        return "ApplicationName = " + this.applicationName + "、EurekaServers = "
                + this.eurekaServers + "、infos = " + infoConfig.toString();
    }
}
